Component({
  data: {
    color: '#999999',
    selColor: '#8adf9b',
    activePath: 'index'
  },
  lifetimes: {
    attached(){ this.updateActive() }
  },
  pageLifetimes: {
    show(){ if(this.updateActive) this.updateActive() }
  },
  methods: {
    updateActive(){
      const pages = getCurrentPages()
      const curr = pages[pages.length-1]
      const route = curr.route || ''
      this.setData({ activePath: route.includes('profile')? 'profile' : 'index' })
    },
    switchTab(e){
      const path = e.currentTarget.dataset.path
      if(path){ wx.switchTab({ url: path }) }
    }
  }
})

